/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IFSv2.Operations;

import IFSv2.Models.mdlMain;
import IFSv2.Forms.Main.frmMain;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

/**
 *
 * @author Joel
 */
public class clsTab extends javax.swing.JPanel implements java.awt.event.ActionListener{

        private javax.swing.JComponent component;
        private javax.swing.JLabel tabLabel;
        private javax.swing.JButton closeTab;
        private String label;
        
        @SuppressWarnings("LeakingThisInConstructor")
        public clsTab(String label, javax.swing.JComponent component){
            super(new java.awt.BorderLayout());
            this.component = component;
            this.label = label;
            ((java.awt.BorderLayout)this.getLayout()).setHgap(5);
            tabLabel = new javax.swing.JLabel(label);
            add(tabLabel, java.awt.BorderLayout.WEST);
            ImageIcon img = new ImageIcon(getClass().getResource("/IFSv2/Images/close.png"));
            closeTab = new javax.swing.JButton(img);
            closeTab.addActionListener(this);
            closeTab.setMargin(new java.awt.Insets(0,0,0,0));
            closeTab.setBorder(null);
            closeTab.setBorderPainted(false);
            add(closeTab, java.awt.BorderLayout.EAST);
        }
    
    @Override
    public void actionPerformed(ActionEvent e) {
        mdlMain.tabMap.remove(label);
        frmMain.menuTabbedPane.remove(component);
        
    }
    
    public String getTitle(){
        return label;
    }
    
    public void setTitle(String title){
        label = title;
        this.tabLabel.setText(title);
    }
}
